﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;


/// <summary>
/// 钩子基类
/// </summary>


class MessageBase
{
    public MessageBase()
    {
    }

    //查找窗口
    [DllImport("User32.dll", EntryPoint = "FindWindow")]
    public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);

    //进程窗口置顶
    [DllImport("User32.dll")]
    public static extern IntPtr SetForegroundWindow(IntPtr hwnd);

    //进程窗口位置关系
    [DllImport("User32.dll", EntryPoint = "SetParent")]
    public static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);

    //模拟键盘事件
    [DllImport("User32.dll")]
    public static extern void keybd_event(Byte bVk, Byte bScan, Int32 dwFlags, Int32 dwExtraInfo);

    //发送消息
    [DllImport("User32.dll", EntryPoint = "PostMessage")]
    public static extern int PostMessage(
        IntPtr hWnd,    //句柄
        int Msg,        //消息
        uint wParam,    //第一次消息参数
        uint lParam     //第二个消息参数
    );
}

